import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persistedstate'

import App from './App.vue'
import router from './router'
//引入执行添加路由
import './router/dynamicAddRouter'

import 'element-plus/dist/index.css'
import  {i18n} from "./i18n/index"
import { useUserInfoStore } from './stores/userInfo'

const app = createApp(App)
app.use(createPinia().use(piniaPluginPersist))
app.use(router)
app.use(i18n)

app.mount('#app')

app.directive('permission',{
    mounted(el,binding){
        const store = useUserInfoStore()
        let val = binding.value
        var permissionList = store.userInfo.perms || []
        if(-1 === permissionList.indexOf(val)){
            el.remove()
        }
    }
})